package protobuf;

import protobuf.domain.MsgBody;
import protostuff.ProtostuffUtils;
import theobj.BlackCat;

public class TTT {
    public static void main(String[] args) {
        showMeTimeAndSize();
    }

    public static void showMeTimeAndSize() {
        // BlackCat black = new BlackCat("black", "我是黑猫");
        MsgBody.Builder msg = MsgBody.newBuilder();
        msg.setColor("black");
        msg.setName("我是黑猫");
        byte[] bytes = msg.build().toByteArray();
//        byte[] bytes = ProtostuffUtils.serialize(black);
        System.out.println("protobuf 大小: " + bytes.length);

//        BlackCat black = new BlackCat("black", "我是黑猫");
        long start = System.currentTimeMillis();
        for (int i = 0; i < 100000; i++) {
            MsgBody.newBuilder().setColor("black").setName("我是黑猫").build().toByteArray();
        }
        System.out.println("protobuf 耗时: " + (System.currentTimeMillis() - start));

    }

}
